#! /bin/bash
###########################################################
#   键盘的快捷开关
#   拷贝到 /use/bin 即可使用
#
###########################################################

keyboard_id=`xinput list | grep "AT T" | egrep -o "id=([0-9]+)"`
ID=${keyboard_id:3}
# echo $ID
is_e=`which xinput`
if [ -z "$is_e" ];then
    echo -e "please install xinput,first.\n    Debian: apt-get install xinput\n    centos: yum install xinput\n"
else
    if [ -z "$1" ];then
        echo -e "Usage:miss option\n    $0 0 is close keyboard\n    $0 1 is open keyboard\n"
    else 
        if [ $1 == '0' ] || [ $1 == '1' ];then
            xinput set-prop $ID "Device Enabled" $1
            echo "Successful"
        else 
            echo -e "Usage:miss option\n    $0 0 is close keyboard\n    $0 1 is open keyboard\n"
        fi
    fi
fi